import { defineStore } from 'pinia'
import { postSearchRequest } from '@/service/module/search/search'

interface Iadmindemo {
  iid: number
  title: string
  paper: string
  image: string
  path: string
  name: string
  content: string
}

export const useSearchStore = defineStore('search', {
  state: () => ({
    searchdemo: [] as Iadmindemo[],
    total: 0,
    iid: 0,
    name: '',
  }),

  actions: {
    async searchResultAction(searchParams: any) {
      //实验  getAdminRequest

      const res = await postSearchRequest(searchParams)

      this.searchdemo = res.data.data.searchAdminListData

      this.total = res.data.data.total
      this.iid = res.data.data.searchAdminListData[0].iid
      console.log(res.data.data, '444444')
    },
  },
  persist: true,
})
